public async Task <IActionResult> PutBroker([FromRoute] int id, [FromBody] pBroker item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.pBrokerId) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrokerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> AddAsync(int agencyId, AddPropertyCommand command) { var propertyModel = Mapper.Map <AddPropertyCommand, Property>(command, opt => opt.AfterMap((src, dest) => dest.AgencyId = agencyId)); _dbContext.Properties.Add(propertyModel); await _dbContext.SaveChangesAsync(); return(propertyModel.Id); }
public async Task <ActionResult> Delete(int id) { try { Doctor doctor = await FindSubscriberAsync(id); _context.Doctors.Remove(doctor); await _context.SaveChangesAsync(); } catch (Exception e) { return(RedirectToAction("Delete", new { id = id, retry = true })); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(int id) { try { Hospital hospital = await FindHospitalAsync(id); _context.Hospitals.Remove(hospital); await _context.SaveChangesAsync(); } catch (Exception e) { return(RedirectToAction("Delete", new { id = id, retry = true })); } return(RedirectToAction("Index")); }
public async Task <List <FirmLoginDto> > CreateFirm(Firm firmDetails) { var rnd = new RNGCryptoServiceProvider(); var sb = new StringBuilder(); var buf = new byte[3]; //length: should be larger rnd.GetBytes(buf); //gives a "valid" range of: "0123456789ABCDEF" foreach (byte b in buf) { sb.AppendFormat("{0:x2}", b); } string passwordHash, passwordSalt; CreatePasswordHash(firmDetails.Password, out passwordHash, out passwordSalt); firmDetails.PasswordHash = passwordHash; firmDetails.PasswordSalt = passwordSalt; firmDetails.LoginId = sb.ToString(); if (firmDetails.imageFile1 == null) { firmDetails.ImageUri = "#"; } else { var imageFileName = firmDetails.imageFile1.FileName; string imageMimeType = firmDetails.imageFile1.ContentType; byte[] imageData = PropertyManager.GetBytes(firmDetails.imageFile1); firmDetails.ImageUri = _blob.UploadFileToBlob(imageFileName, imageData, imageMimeType); } List <Firm> firmsCreated = ListofCreatedFirms(firmDetails); _db.AddRange(firmsCreated); await _db.SaveChangesAsync(); // return new FirmLoginDto(){ // LoginId = firmDetails.LoginId, // Password = firmDetails.Password, // Id = firmDetails.Id // }; foreach (var item in firmsCreated) { _subRepo.CreateSubscription(item.LoginId, item.Plan, item.Email); } return(LoginDetails(firmsCreated)); }
public async Task <bool> ToggleInterestAsync(string propertyId, string userId) { var property = await _propertyDbContext.Properties.Include(x => x.Interests).SingleAsync(x => x.Id == propertyId).ConfigureAwait(false); var interest = property.Interests.SingleOrDefault(x => x.CustomerIdentityId == userId); var hasInterest = false; if (interest == null) { _propertyDbContext.Add(new PropertyInterest { CustomerIdentityId = userId, Property = property }); hasInterest = true; } else { property.Interests.Remove(interest); } await _propertyDbContext.SaveChangesAsync().ConfigureAwait(false); return(hasInterest); }
public async Task <OnSaleProperty> AddOnSaleProperty(OnSaleProperty property) { if (property != null) { property.IsActive = true; IFormFile[] files = new IFormFile[] { property.imageFile1, property.imageFile2, property.imageFile3, property.imageFile4 }; string[] fileLinks = new string[] { property.ImageLink1, property.ImageLink2, property.ImageLink3, property.ImageLink4 }; for (int i = 0; i < files.Length; i++) { if (files[i] == null) { fileLinks[i] = "#"; } else { fileLinks[i] = GetFileUploadBlobReturnsLink(files[i]); } } property.ImageLink1 = fileLinks[0]; property.ImageLink2 = fileLinks[1]; property.ImageLink3 = fileLinks[2]; property.ImageLink4 = fileLinks[3]; _db.OnSaleProperties.Add(property); await _db.SaveChangesAsync(); return(property); } return(null); }