internal void AddEmployee(tblEmployee employee, tblAccount account, string dateOfBirth, tblEngagement Engagement) { using (HotelEntities1 context = new HotelEntities1()) { DateTime date = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); tblAccount newAccount = new tblAccount(); newAccount.FullName = account.FullName; newAccount.DateOfBirth = date; newAccount.Email = account.Email; newAccount.UserName = account.UserName; newAccount.Pass = account.Pass; context.tblAccounts.Add(newAccount); context.SaveChanges(); tblEmployee newManager = new tblEmployee(); newManager.AccountID = newAccount.AccountID; newManager.HotelFloor = employee.HotelFloor; newManager.Gender = employee.Gender; newManager.Cityzenship = employee.Cityzenship; newManager.EngagementID = Engagement.EngagementID; newManager.Salary = employee.Salary; context.tblEmployees.Add(newManager); context.SaveChanges(); } }
public HttpResponseMessage PostOrEditFoods(Food bs) { try { if (bs.FoodId == 0) { Food c = new Food(); c.Dishes = bs.Dishes; c.Quantity = bs.Quantity; c.Price = bs.Price; mb.Foods.Add(c); mb.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.Created)); } else { var obj = mb.Foods.Where(x => x.FoodId == bs.FoodId).ToList().FirstOrDefault(); if (obj.FoodId > 0) { obj.Dishes = bs.Dishes; obj.Quantity = bs.Quantity; obj.Price = bs.Price; mb.SaveChanges(); } return(new HttpResponseMessage(HttpStatusCode.OK)); } } catch (Exception e) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
internal void AddManager(tblManager manager, tblAccount account, string dateOfBirth) { using (HotelEntities1 context = new HotelEntities1()) { DateTime date = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); tblAccount newAccount = new tblAccount(); newAccount.FullName = account.FullName; newAccount.DateOfBirth = date; newAccount.Email = account.Email; newAccount.UserName = account.UserName; newAccount.Pass = account.Pass; context.tblAccounts.Add(newAccount); context.SaveChanges(); tblManager newManager = new tblManager(); newManager.AccountID = newAccount.AccountID; newManager.HotelFloor = manager.HotelFloor; newManager.Experience = manager.Experience; newManager.QualificationsLevel = manager.QualificationsLevel; context.tblManagers.Add(newManager); context.SaveChanges(); } }