public ActionResult CreateSvc(Service NewService) { var account = new AccountController(); var currentUser = account.UserManager.FindById(User.Identity.GetUserId()); //perform db operation to add svc this._svcTrtmntRepository.AddNewService(currentUser.CompanyID, NewService); return RedirectToAction("Index"); }
/// <summary> /// Add new service /// </summary> /// <param name="companyID"></param> /// <param name="NewService"></param> public void AddNewService(Int64 companyID, Service NewService) { this._con.Insert(new Service { CompanyID = companyID, ServiceName = NewService.ServiceName, ServiceDesc = NewService.ServiceDesc }); }
/// <summary> /// update svc /// </summary> /// <param name="companyID"></param> /// <param name="UpdatedService"></param> public void UpdateService(Int64 companyID, Service UpdatedService) { //this._con.Update(UpdatedService); Issue with update - it deletes record :-| string qryUpdate = String.Format(@"update [dbo].[Service] set ServiceName = '{0}', ServiceDesc = '{1}' where ServiceID = {2} and CompanyID = {3}" , UpdatedService.ServiceName , UpdatedService.ServiceDesc , UpdatedService.ServiceID , companyID ); this._con.Execute(qryUpdate, UpdatedService); }