Tuesday, July 31, 2012
Thursday, July 19, 2012
Visual studio command here.
Name the file : vsnet2010cmdhere.inf
Code Snippet
- ;
- ; "CMD Prompt Here" PowerToy
- ;
- ; Copyright 1996 Microsoft Corporation
- ;
- [version]
- signature="$CHICAGO$"
- [VSNet2010CmdHereInstall]
- CopyFiles = VSNet2010CmdHere.Files.Inf
- AddReg = VSNet2010CmdHere.Reg
- [DefaultInstall]
- CopyFiles = VSNet2010CmdHere.Files.Inf
- AddReg = VSNet2010CmdHere.Reg
- [DefaultUnInstall]
- DelFiles = VSNet2010CmdHere.Files.Inf
- DelReg = VSNet2010CmdHere.Reg
- [SourceDisksNames]
- 55="VS 2010 CMD Prompt Here","",1
- [SourceDisksFiles]
- VSNet2010CmdHere.INF=55
- [DestinationDirs]
- VSNet2010CmdHere.Files.Inf = 17
- [VSNet2010CmdHere.Files.Inf]
- VSNet2010CmdHere.INF
- [VSNet2010CmdHere.Reg]
- HKLM,%UDHERE%,DisplayName,,"%VSNet2010CmdHereName%"
- HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll,SetupInfObjectInstallAction DefaultUninstall 132 %17%\VSNet2010CmdHere.inf"
- HKCR,Directory\Shell\VSNet2010CmdHere,,,"%VSNet2010CmdHereAccel%"
- HKCR,Directory\Shell\VSNet2010CmdHere\command,,,"%11%\cmd.exe /k cd ""%1"" && ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86"
- HKCR,Drive\Shell\VSNet2010CmdHere,,,"%VSNet2010CmdHereAccel%"
- HKCR,Drive\Shell\VSNet2010CmdHere\command,,,"%11%\cmd.exe /k cd ""%1"""
- [Strings]
- VSNet2010CmdHereName="VS 2010 Command Prompt Here PowerToy"
- VSNet2010CmdHereAccel="VS 20&10 CMD Prompt Here"
- UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\VSNet2010CmdHere"
Code Snippet
- ;
- ; "CMD Prompt Here" PowerToy
- ;
- ; Copyright 1996 Microsoft Corporation
- ;
- [version]
- signature="$CHICAGO$"
- [VSNet2010CmdHereInstall]
- CopyFiles = VSNet2010CmdHere.Files.Inf
- AddReg = VSNet2010CmdHere.Reg
- [DefaultInstall]
- CopyFiles = VSNet2010CmdHere.Files.Inf
- AddReg = VSNet2010CmdHere.Reg
- [DefaultUnInstall]
- DelFiles = VSNet2010CmdHere.Files.Inf
- DelReg = VSNet2010CmdHere.Reg
- [SourceDisksNames]
- 55="VS 2010 CMD Prompt Here","",1
- [SourceDisksFiles]
- VSNet2010CmdHere.INF=55
- [DestinationDirs]
- VSNet2010CmdHere.Files.Inf = 17
- [VSNet2010CmdHere.Files.Inf]
- VSNet2010CmdHere.INF
- [VSNet2010CmdHere.Reg]
- HKLM,%UDHERE%,DisplayName,,"%VSNet2010CmdHereName%"
- HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll,SetupInfObjectInstallAction DefaultUninstall 132 %17%\VSNet2010CmdHere.inf"
- HKCR,Directory\Shell\VSNet2010CmdHere,,,"%VSNet2010CmdHereAccel%"
- HKCR,Directory\Shell\VSNet2010CmdHere\command,,,"%11%\cmd.exe /k cd ""%1"" && ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86"
- HKCR,Drive\Shell\VSNet2010CmdHere,,,"%VSNet2010CmdHereAccel%"
- HKCR,Drive\Shell\VSNet2010CmdHere\command,,,"%11%\cmd.exe /k cd ""%1"""
- [Strings]
- VSNet2010CmdHereName="VS 2010 Command Prompt Here PowerToy"
- VSNet2010CmdHereAccel="VS 20&10 CMD Prompt Here"
- UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\VSNet2010CmdHere"
Friday, May 11, 2012
How to convert a list into neat html table to display in UI.
I have look all over the internet to see if someone has written code that converts the enumerable list in C# and return you a html table so that you can directly display it on UI. No luck. Here is what I have got I hope it helps someone. This code is test
Code Snippet
- public string GetAssociationValues()
- {
- IEnumerable<string> results = _omniService.GetAllAssociations();
- // format a list into table of check boxes.
- var sbTable = new StringBuilder();
- var sbRows = new StringBuilder();
- var sbColumns = new StringBuilder();
- int counter = 0;
- foreach (string result in results)
- {
- sbColumns.AppendFormat("<td><input type='checkbox' name='ImproveResultsAssociation' value='{0}' id='{0}'><span class='resAssociationText'>{0}</span></td>", result);
- counter++;
- // change the 2 to what ever number of columns you want to display the text.
- if (counter % 2 == 0)
- {
- sbRows.Append("<tr>" + sbColumns.ToString() + "</tr>");
- sbColumns.Clear();
- }
- }
- // last check if we are missing anything.
- if (sbColumns.Length>0)
- {
- sbRows.Append("<tr>" + sbColumns.ToString() + "</tr>");
- }
- sbTable.Append("<table>" + sbRows.ToString() + "</table>");
- return sbTable.ToString();
- }
How to create a modal window in jQuery.
Code Snippet
- $(function () {
- $('#iDialog').dialog({
- autoOpen: false,
- width: 800,
- height: 400,
- resizable: false,
- modal: true,
- buttons: [{ text: "Ok", click: function () { $(this).dialog("close"); } }]
- });
- });
- $(document).ready(function () {
- $('#show-modal-industry').click(function () {
- $('#iDialog').load(industryUrl, function () {
- $('#iDialog').dialog('open');
- });
- return false;
- });
- });
- $(function () {
- $('#aDialog').dialog({
- autoOpen: false,
- width: 800,
- height: 400,
- resizable: false,
- modal: true,
- buttons: [{ text: "Ok", click: function () {
- alert('Hello World'); $(this).dialog("close"); } }]
- });
- });
- $(document).ready(function () {
- $('#show-modal-association').click(function () {
- $('#aDialog').load(associationUrl, function () {
- $('#aDialog').dialog('open');
- });
- return false;
- });
- });
Code Snippet
- <div id="iDialog" title="Industry">
- </div>
- <div id="aDialog" title="Association">
- </div>
- <script type="text/javascript">
- var industryUrl = '@Url.Action("GetIndustryInfo", "Home")';
- var associationUrl = '@Url.Action("GetAssociationInfo", "Home")';
- </script>
Friday, April 27, 2012
How import/export data from sqlserver to mdf file in visual studio.
I dont have time to write detailed explanation but I will try and get that done today or tomorrow.
I used sql management studio.
I connect to sql server using to connect to source.
Then I connected to destination by connecting to mdf file inside visual studio project.
Then I tried to look into import and export by right clicking on tables but my efforts went in vain. Now I tried something different.
I tried and used
then I was able to this below
insert into [dbo].[Taxonomy]
select * from [server].[Omni].[dbo].[Taxonomy]
after then I removed the server
sp_dropserver 'myservername'
I will try and post the images so that it will be easy for others to read.
I used sql management studio.
I connect to sql server using to connect to source.
Then I connected to destination by connecting to mdf file inside visual studio project.
Then I tried to look into import and export by right clicking on tables but my efforts went in vain. Now I tried something different.
I tried and used
sp_addlinkedserver 'myservername'
then I was able to this below
insert into [dbo].[Taxonomy]
select * from [server].[Omni].[dbo].[Taxonomy]
after then I removed the server
sp_dropserver 'myservername'
I will try and post the images so that it will be easy for others to read.
Thursday, April 26, 2012
Design class to handle processing times in a distributed environment.
Code Snippet
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- namespace Import.Data
- {
- /// <summary>
- /// Class that stores execution times, messages and other
- /// information required to generate exception report for
- /// import process
- /// </summary>
- public class SyncResultItemNew : IDisposable
- {
- #region Private Variables
- private readonly List<SyncResultItemNew> _childern;
- private readonly Dictionary<string, string> _parameters;
- private readonly bool _shouldFallThrough;
- private readonly Stopwatch _stopWatch;
- private string _action;
- private string _description;
- private TimeSpan _duration;
- private string _logicalStep;
- private SyncResultType _resultType;
- #endregion
- #region PrivateMethods
- private string SubstituteParamName(string paramName)
- {
- string baseParamName = paramName;
- string actualParamName = paramName;
- int index = 0;
- while (_parameters.ContainsKey(actualParamName))
- {
- actualParamName = baseParamName + "(" + ++index + ")";
- }
- return actualParamName;
- }
- #endregion
- #region Constructor
- /// <param name="stepName">Name of the step.</param>
- /// <remarks>
- /// If step name is not provided then
- /// step name is set to "Unknown"
- /// </remarks>
- private SyncResultItemNew(string stepName)
- {
- _logicalStep = !string.IsNullOrEmpty(stepName) ? stepName : "Unknown";
- _stopWatch = Stopwatch.StartNew();
- _parameters = new Dictionary<string, string>();
- _childern = new List<SyncResultItemNew>();
- _action = string.Empty;
- _description = string.Empty;
- _shouldFallThrough = false;
- _resultType = SyncResultType.Success;
- }
- #endregion
- #region Public Properties
- /// <summary>
- /// Gets a value indicating whether code processing should fall through or not.
- /// </summary>
- /// <value><c>true</c> if code processing should fall through otherwise, <c>false</c>.</value>
- public bool ShouldFallThrough
- {
- get { return _shouldFallThrough; }
- }
- #endregion
- #region IDisposable Members
- void IDisposable.Dispose()
- {
- if (_stopWatch != null)
- {
- _stopWatch.Stop();
- _duration = _stopWatch.Elapsed;
- }
- }
- #endregion
- #region Public Methods
- /// <summary>
- /// Creates a parent that stores all the necessary information required
- /// for exception report and stores execution times of all the logical steps.
- /// </summary>
- /// <param name="stepName">Name of the step.</param>
- /// <returns>
- /// A newly created instance of the <see cref="SyncResultItemNew"/> class
- /// that stores all information required for exception reporting after
- /// import process.
- /// </returns>
- /// <exception cref="ObjectDisposedException">Object is already disposed.</exception>
- /// <remarks>
- /// If step name is not provided, then root is created with name "Unknown".
- /// </remarks>
- public static SyncResultItemNew CreateRoot(string stepName)
- {
- return new SyncResultItemNew(stepName);
- }
- /// <summary>
- /// Creates a child of <see cref="SyncResultItemNew"/> name with logical step
- /// under a parent <see cref="SyncResultItemNew"/>.
- /// </summary>
- /// <param name="stepName">Name of the step.</param>
- /// <returns>
- /// A newly created child instance of the <see cref="SyncResultItemNew"/> class
- /// that stores all information required for exception reporting after
- /// import process under a parent.
- /// </returns>
- /// <exception cref="ObjectDisposedException">Object is already disposed.</exception>
- /// <remarks>
- /// If no step name is provided then child will be
- /// created with step name "Unknown".
- /// </remarks>
- public SyncResultItemNew CreateChild(string stepName)
- {
- var syncResultItemNew = new SyncResultItemNew(stepName);
- _childern.Add(syncResultItemNew);
- return syncResultItemNew;
- }
- /// <param name="paramName">Name of the parameter.</param>
- /// <param name="paramValue">Value of the parameter</param>
- /// <remarks>
- /// If parameter name is not provided then parameter name would be defaulted
- /// to "Key". If an existing parameter name is provided then code
- /// increments the parameter name and then add it to collection
- /// </remarks>
- public void AddParam(string paramName, string paramValue)
- {
- paramName = string.IsNullOrEmpty(paramName) ? "Key" : paramName;
- if (!_parameters.ContainsKey(paramName))
- {
- _parameters.Add(paramName, paramValue);
- }
- else
- {
- _parameters.Add(SubstituteParamName(paramName), paramValue);
- }
- }
- /// <param name="ex">The exception that needs to be added to collection</param>
- /// <remarks>
- /// If proper exception is not passed, then the exception
- /// messages are ignored/not stored. If this method is called more
- /// than once within the the scope/context of the object and exception is
- /// provided exception messages are added to collection with an incremented key.
- /// </remarks>
- public void AddUnexpectedError(Exception ex)
- {
- if (ex != null)
- {
- AddParam("Message", ex.Message);
- }
- }
- /// <param name="syncResultType">Type of the sync result.</param>
- /// <param name="description">The description that needs to be added.</param>
- /// <remarks>
- /// Populates result type, description. If description is not passed then
- /// description is substituted with default description, "No Description".
- /// If this method is called more than once within the the scope/context of the
- /// object then previous description and result type are overwritten.
- /// </remarks>
- public void AddResult(SyncResultType syncResultType, string description)
- {
- _resultType = syncResultType;
- _description = !string.IsNullOrEmpty(description) ? description : "No Description";
- }
- /// <param name="syncResultType">Type of sync result.</param>
- /// <param name="description">Description that needs to be set.</param>
- /// <param name="ex">The exception that needs to be added to collection.</param>
- /// <remarks>
- /// Populates result type, description and exception
- /// If description is not passed then description is substituted with default
- /// description "No Description". If proper exception is not passed then exception
- /// messages are ignored and not added to collection. If this method is called more than
- /// once within the the scope/context of the object then previous description and result
- /// type are overwritten. If exception is provided new exception messages are
- /// stored with an incremented key.
- /// </remarks>
- public void AddResult(SyncResultType syncResultType, string description, Exception ex)
- {
- _resultType = syncResultType;
- _description = !string.IsNullOrEmpty(description) ? description : "No Description";
- if (ex != null)
- {
- AddParam("Message", ex.Message);
- }
- }
- #endregion
- }
- }
How to gracefully add an existing key to dictionary c#
I have
written some code that will gracefully add a key to dictionary. The goal was not to throw exception even if someone adds a key accidentally. There are many arguments around this but it is the design that drove us to this. We could use a list that stores a class of Param with key and value as properties.
Code Snippet
- using System;
- using System.Collections.Generic;
- namespace Example
- {
- internal class Program
- {
- private static readonly Dictionary<string, int> dict = new Dictionary<string, int>();
- public static void Main(string[] args)
- {
- #region JunkCode
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- AddParam("key", 0);
- #endregion
- foreach (var kvp in dict)
- {
- Console.WriteLine(kvp.Key);
- }
- Console.Read();
- }
- private static void AddParam(string key, int value)
- {
- if (!dict.ContainsKey(key))
- {
- dict.Add(key, value);
- }
- else
- {
- dict.Add(SubstituteParamName(key), value);
- }
- }
- private static string SubstituteParamName(string paramName)
- {
- string baseParamName = paramName;
- string actualParamName = paramName;
- int index = 0;
- while (dict.ContainsKey(actualParamName))
- {
- actualParamName = baseParamName + "(" + ++index + ")";
- }
- return actualParamName;
- }
- }
- }
Friday, April 13, 2012
Today I was asked to write a routine that enhances cleaning of urls.
What I need to do is clean the url field so that the crawlers can crawl the website.
Ex. http://www.abc.com/welcome.html
http://www.msn.com/default/
should be converted to
http://www.abc.com
http://www.msn.com
What I need to do is clean the url field so that the crawlers can crawl the website.
Ex. http://www.abc.com/welcome.html
http://www.msn.com/default/
should be converted to
http://www.abc.com
http://www.msn.com
Code Snippet
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace ScrubWebUrl
- {
- class Program
- {
- static void Main(string[] args)
- {
- #region "Scrub url examples"
- List<string> weburls = new List<string>();
- weburls.Add(string.Empty);
- weburls.Add("");
- weburls.Add("http://www.yahoo.co.in/index.html");
- weburls.Add("http://www.yahoo.ca/index/main.asp");
- weburls.Add("http://blogger.yahoo.ca/index/main.aspx");
- weburls.Add("http://www.yahoo.ca/yahoo/main.jsp");
- weburls.Add("http://www.rediff.ca/mail/sell/ma.ashx");
- weburls.Add("http://3ww.janus.com/account/securelogin/");
- weburls.Add("http://2ww.xca/index/secure/main");
- weburls.Add("http://www.maquet.com");
- weburls.Add("http://ca.maquet.com");
- weburls.Add("http://www.datascope.com");
- weburls.Add("http://www.datascope.com/index.html");
- weburls.Add("http://www.rediff.com/abc/crap.html");
- weburls.Add("http://www.mnghardware.com");
- weburls.Add("http://anzaexotics.com/home");
- weburls.Add("http://www.empowercom.net");
- weburls.Add("http://www.cgulfc.com/home.asp");
- weburls.Add("http://www.chefrubber.com");
- weburls.Add("http://www.mathers-team.com");
- weburls.Add("http://www.2crave.com");
- weburls.Add("http://www.tmgwest.com");
- weburls.Add("http://www.next-communications.com");
- weburls.Add("http://www.nextcom.com");
- weburls.Add("http://www.fishertracks.com");
- weburls.Add("http://www.summitengineer.net");
- weburls.Add("http://www.cablofil.com");
- weburls.Add("http://safety.det-tronics.com");
- weburls.Add("http://www.detronics.com/utcfs/templates/pages/template-46/1,8060,pageid=2494&siteid=462,00.html");
- weburls.Add("http://www.detronics.com");
- weburls.Add("http://www.ixp.tz.net");
- weburls.Add("http://clev11.com/~composi1");
- weburls.Add("http://saint-joseph.michiganpages.org/c-224509.htm");
- weburls.Add("http://www.marriott.com/hotels/travel/atlrb-renaissance-atlanta-waverly-hotel");
- weburls.Add("http://www.chevron.com/about/our_businesses/mining.asp");
- weburls.Add("http://www.tria.com/sports_medicine_fellowship.aspx");
- weburls.Add("http://www.cgc-jp.com/products/finechemicals/index.html");
- weburls.Add("http://www.pollockpaper.com/packaging.asp");
- weburls.Add("http://alliedhightech.com/imaging");
- weburls.Add("http://www.as.ua.edu/english/03_graduate/maphd");
- weburls.Add("http://www.publicautoauctionassoc.org");
- weburls.Add("http://www.clubsafetysolutions.com");
- weburls.Add("http://www.groupe.e.ch");
- weburls.Add("http://www.distel.nl");
- weburls.Add("http://www.familydoctor.org/valleyhealthw");
- weburls.Add("http://www.importcostumes.com/pony+express+creations,+inc.html");
- weburls.Add("http://www.faseb.org/society-management-services/project-management-services.aspx");
- weburls.Add("http://www.mindware.it/masterpack");
- weburls.Add("http://www.water-softeners-filters.com");
- weburls.Add("http://www.aspengrovekitchenandbath.com");
- weburls.Add("http://www.stratatechcorp.com/products/stratatest.php");
- weburls.Add("http://www.tri3bar.com");
- weburls.Add("http://www.brownandsharpe.com/?utm_source=agma&utm_medium=listing&utm_campaign=gears");
- // weburls.Add("http://www.brownandsharpe.com www.hexagonmetrology.us");
- weburls.Add("http://www.hexagonmetrology.us/?utm_source=sae&utm_medium=directory_listing&utm_campaign=hexagon");
- weburls.Add("http://www.mobibon.com.tw");
- weburls.Add("http://www.pivotalhealthsolutions.com/default.aspx");
- weburls.Add("http://www.pivotalhealthsolutions.com/athletics");
- weburls.Add("http://www.aspengrovekitchenandbath.com");
- weburls.Add("http://www.stratatechcorp.com/products/stratatest.php");
- weburls.Add("http://www.tri3bar.com");
- weburls.Add("http://www.brownandsharpe.com/?utm_source=agma&utm_medium=listing&utm_campaign=gears");
- // weburls.Add("http://www.brownandsharpe.com www.hexagonmetrology.us");
- weburls.Add("http://www.hexagonmetrology.us/?utm_source=sae&utm_medium=directory_listing&utm_campaign=hexagon");
- weburls.Add("http://www.mobibon.com.tw");
- weburls.Add("http://www.pivotalhealthsolutions.com/default.aspx");
- weburls.Add("http://www.pivotalhealthsolutions.com/athletics");
- weburls.Add("http://www.faseb.org/society-management-services/project-management-services.aspx");
- weburls.Add("http://www.importcostumes.com/pony+express+creations,+inc.html");
- #endregion
- ScrubTheseUrls(weburls);
- }
- private static void ScrubTheseUrls(List<string> weburls)
- {
- Console.WriteLine("The input urls count is :" + weburls.Count);
- List<string> scrubbedUrls = new List<string>();
- foreach (string oldurl in weburls)
- {
- scrubbedUrls.Add(Scrbber(oldurl));
- }
- foreach (string newurl in scrubbedUrls)
- {
- Console.WriteLine(newurl);
- }
- Console.WriteLine("The scrubbed urls count is :" + scrubbedUrls.Count);
- Console.ReadKey();
- }
- private static string Scrbber(string oldurl)
- {
- string regexp = "http://*[^/]*";
- return Regex.Match(oldurl, regexp).Value;
- }
- }
- }
Tuesday, April 3, 2012
Entity Framework ITHotList Controller
Code Snippet
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.Entity;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using ITHotList.Models;
- using System.Web.Security;
- namespace ITHotList.Controllers
- {
- public class HotListController : Controller
- {
- private HotListEntities db = new HotListEntities();
- //
- // GET: /HotList/
- [Authorize]
- public ViewResult Index()
- {
- MembershipUser user = Membership.GetUser();
- Guid userId = (Guid)user.ProviderUserKey;
- return View(db.HotLists.Where(hotlist => hotlist.UserId == userId).OrderByDescending(hotlist => hotlist.CreateDate).ToList());
- }
- //
- // GET: /HotList/Details/5
- [Authorize]
- public ViewResult Details(int id)
- {
- HotList hotlist = db.HotLists.Find(id);
- return View(hotlist);
- }
- //
- // GET: /HotList/Create
- [Authorize]
- public ActionResult Create()
- {
- HotList hotlistModel = new HotList();
- hotlistModel.Name = "Name";
- hotlistModel.Resources.Add(new Resource() { Name = "", Availability= "", CurrentLocation="", ImmigrationStatus ="", JobRole="", PreferredLocation="", Rate ="", LinkToResume="", Skill="", YearsOfExp = 0 });
- return View(hotlistModel);
- }
- //
- // POST: /HotList/Create
- [Authorize]
- [HttpPost]
- public JsonResult Create(HotList receivedhotlist)
- {
- // never trust what has come from ui.
- string message = string.Empty;
- try
- {
- HotList hotlist = new HotList();
- if (ModelState.IsValid)
- {
- MembershipUser user = Membership.GetUser();
- Guid userId = (Guid)user.ProviderUserKey;
- hotlist.UserId = userId;
- try
- {
- hotlist.Active = true;
- hotlist.Name = receivedhotlist.Name;
- hotlist.CreateDate = DateTime.Now;
- var profile = Profile.GetProfile(user.UserName);
- if (profile.CompanyName != null)
- {
- hotlist.CompanyName = profile.CompanyName;
- }
- if (user.Email != null)
- {
- hotlist.Email = user.Email;
- }
- if (profile.PrimaryPhoneNumber != null)
- {
- hotlist.PrimaryPhoneNumber = profile.PrimaryPhoneNumber;
- }
- if (profile.PrimaryExt != null)
- {
- hotlist.PrimaryExt = profile.PrimaryExt;
- }
- if (profile.SecondaryPhoneNumber != null)
- {
- hotlist.SecondaryPhoneNumber = profile.SecondaryPhoneNumber;
- }
- if (profile.SecondaryExt != null)
- {
- hotlist.SecondaryExt = profile.SecondaryExt;
- }
- if (profile.Fax != null)
- {
- hotlist.Fax = profile.Fax;
- }
- // Error is happening here.. need to fix it.
- }
- catch { }
- foreach (Resource receivedresource in receivedhotlist.Resources)
- {
- Resource resource = new Resource();
- resource.Active = true;
- resource.UserId = userId;
- resource.JobRole = receivedresource.JobRole;
- resource.Availability = receivedresource.Availability;
- resource.CurrentLocation = receivedresource.CurrentLocation;
- resource.ImmigrationStatus = receivedresource.ImmigrationStatus;
- resource.LinkToResume = receivedresource.LinkToResume;
- resource.Name = receivedresource.Name;
- resource.PreferredLocation = receivedresource.PreferredLocation;
- resource.Rate = receivedresource.Rate;
- resource.Skill = receivedresource.Skill;
- resource.YearsOfExp = receivedresource.YearsOfExp;
- resource.HotLists.Add(hotlist);
- hotlist.Resources.Add(resource);
- db.Resources.Add(resource);
- }
- db.HotLists.Add(hotlist);
- db.SaveChanges();
- //do the persistence logic here
- message = "SUCCESS";
- }
- else
- {
- message = "modelstate is invalid";
- }
- }
- catch (Exception ex)
- {
- message = ex.Message.ToString();
- }
- return Json(message);
- }
- //[HttpPost]
- //public ActionResult Create(HotList hotlist)
- //{
- // if (ModelState.IsValid)
- // {
- // MembershipUser user = Membership.GetUser();
- // Guid userId = (Guid)user.ProviderUserKey;
- // hotlist.UserId = userId;
- // hotlist.CreateDate = DateTime.Now;
- // db.HotLists.Add(hotlist);
- // db.SaveChanges();
- // return RedirectToAction("Index");
- // }
- // return View(hotlist);
- //}
- //
- // GET: /HotList/Edit/5
- [Authorize]
- public ActionResult Edit(int id)
- {
- HotList hotlist = db.HotLists.Find(id);
- return View(hotlist);
- }
- //
- // POST: /HotList/Edit/5
- [Authorize]
- [HttpPost]
- public ActionResult Edit(HotList hotlist)
- {
- if (ModelState.IsValid)
- {
- db.Entry(hotlist).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(hotlist);
- }
- //
- // GET: /HotList/Delete/5
- [Authorize]
- public ActionResult Delete(int id)
- {
- HotList hotlist = db.HotLists.Find(id);
- return View(hotlist);
- }
- //
- // POST: /HotList/Delete/5
- [Authorize]
- [HttpPost, ActionName("Delete")]
- public ActionResult DeleteConfirmed(int id)
- {
- HotList hotlist = db.HotLists.Find(id);
- db.HotLists.Remove(hotlist);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- protected override void Dispose(bool disposing)
- {
- db.Dispose();
- base.Dispose(disposing);
- }
- }
- }
Subscribe to:
Posts (Atom)