public override async Task <Model.Response.Employee> InsertAsync(Model.Request.Employee entity) { Database.Employee model = mapper.Map <Database.Employee>(entity); try { Model.Response.ApplicationUser user = await UserService.InsertAsync(entity.User, Model.Enum.Enum.Roles.Employee); model.ApplicationUserId = user.ID; ctx.Employees.Add(model); await ctx.SaveChangesAsync(); if (entity.ProfilePhoto != null) { entity.ProfilePhoto.ApplicationUserId = user.ID; await ProfilePhotoService.InsertAsync(entity.ProfilePhoto); } // TODO: Dodati log operaciju } catch (Exception e) { //TODO: Dodati log operaciju throw e; } return(mapper.Map <Model.Response.Employee>(model)); }
public async Task <IActionResult> Update(int id) { Model.Response.ApplicationUser model = await CrudService.GetByIdAsync(id); if (model != null) { return(View(model)); } return(NotFound()); }
public override async Task <Client> InsertAsync(Model.Request.Client entity) { Database.Client client = mapper.Map <Database.Client>(entity); try { Model.Response.ApplicationUser user = await UserService.InsertAsync(entity.ApplicationUserInsert, Enum.Roles.User); Model.Response.Person person = await PersonService.InsertAsync(entity.Person); client.ApplicationUserId = user.ID; client.PersonId = person.ID; ctx.Clients.Add(client); await ctx.SaveChangesAsync(); // TODO: Dodati log } catch (Exception e) { // TODO: Dodati log throw e; } return(mapper.Map <Model.Response.Client>(client)); }