Exemplo n.º 1
0
        public async Task<ActionResult> CompanyEdit(CompanyModel model) {
            if(!ModelState.IsValid) {
                return View();
            }

            var editModel = db.Company.Where(c => c.Id.Equals(model.Id)).First();

            if(editModel == null) {
                new HttpStatusCodeResult(HttpStatusCode.NotFound);
            }

            editModel.Id = model.Id;
            editModel.Delatnost = model.Delatnost;
            editModel.MaticniBroj = model.MaticniBroj;
            editModel.OrganizationName = model.OrganizationName;
            editModel.PIB = model.PIB;
            editModel.usersAplication = model.usersAplication;

            await db.SaveChangesAsync();

            return RedirectToAction("CompanyIndex");
        }
Exemplo n.º 2
0
 public async Task<ActionResult> CompanyRegistration(CompanyModel model) {
     ApplicationDbContext db = HttpContext.GetOwinContext().Get<ApplicationDbContext>();
     if(ModelState.IsValid) {
         model.usersAplication = UserManager.FindById(User.Identity.GetUserId());
         if(model.usersAplication != null) {
             model.Id = Guid.NewGuid().ToString();
             db.Company.Add(model);
             UserManager.FindById(User.Identity.GetUserId()).FinishedRegistration = true;
             await db.SaveChangesAsync();
         }
     }
     return RedirectToAction("Index", "Manage");
 }