public ApplicationUser Create(ApplicationUser applicationUser)
 {
     if (IsPermissionAllowed(applicationUser))
     {
         int tenantId = applicationUser.UserTenants.FirstOrDefault().TenantId;
         applicationUser.UserTenants = null;
         bool userSucceeded = _accountProvider.Create(applicationUser, applicationUser.TemporaryCode);
         if (userSucceeded)
         {
             bool            roleSucceeded = _accountProvider.AddToRole(applicationUser.Id, applicationUser.TemporaryRole);
             Tenant          tenant        = _db.Tenants.FirstOrDefault(t => t.TenantId == tenantId);
             ApplicationUser reloadedUser  = _db.Users.Include(t => t.UserTenants).FirstOrDefault(u => u.Id == applicationUser.Id);
             reloadedUser.UserTenants = new List <Tenant>
             {
                 tenant
             };
             _db.Entry(reloadedUser).State = EntityState.Modified;
             _db.SaveChanges();
         }
         else
         {
             Errors = new string[] { "User name already exists" };
         }
     }
     return(applicationUser);
 }
        // GET: Contacts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contact contact = db.Contacts.Find(id);

            contact.MessageRead     = true;
            db.Entry(contact).State = EntityState.Modified;
            db.SaveChanges();
            if (contact == null)
            {
                return(HttpNotFound());
            }
            return(View(contact));
        }
 public ActionResult Edit([Bind(Include = "LookupTypeId,Description,CreatedDate,UpdatedDate")] LookupType lookupType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lookupType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lookupType));
 }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "TenantId,Name,CreatedDate,UpdatedDate")] Tenant tenant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tenant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tenant));
 }
 public ActionResult Edit([Bind(Include = "LookupId,Description,LookupTypeId,CreatedDate,UpdatedDate")] Lookup lookup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lookup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LookupTypeId = new SelectList(db.LookupTypes, "LookupTypeId", "Description", lookup.LookupTypeId);
     return(View(lookup));
 }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "QuoteRequestId,DateRequired,Quantity,SpecificationDetails,QuoteResponseId")] QuoteRequest quoteRequest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quoteRequest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.QuoteRequestId = new SelectList(db.QuoteResponses, "QuoteReposonseId", "Notes", quoteRequest.QuoteRequestId);
     return(View(quoteRequest));
 }
        /// <summary>
        /// Edit the entity if user has tenant permission
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public virtual T Edit(T entity)
        {
            IList <int> tenants = GetTenantIds();

            if (tenants.Contains(entity.TenantId))
            {
                entity.TenantId = entity.TenantId;
                dbContext.Entry(entity).State = System.Data.Entity.EntityState.Modified;
            }
            return(entity);
        }
 public ActionResult Edit([Bind(Include = "QuoteReposonseId,QuoteCostPerItem,QuoteCostTotal,Notes,QuoteRequestId")] QuoteResponse quoteResponse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quoteResponse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.QuoteReposonseId = new SelectList(db.QuoteRequests, "QuoteRequestId", "SpecificationDetails", quoteResponse.QuoteReposonseId);
     return(View(quoteResponse));
 }
 public ApplicationUser EditUser(ApplicationUser user)
 {
     _context.Entry(user).State = EntityState.Modified;
     _context.SaveChanges();
     return(user);
 }
Exemple #10
0
        public async Task UpdateAsync(T entity)
        {
            _context.Entry(entity).State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }
 /// <summary>
 /// Edit the entity
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public T Edit(T entity)
 {
     _db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     return(entity);
 }