public GuestDto DeleteGuest(int GuestID, dugunEntities _context) { Guest guest = _context.Guest.Where(x => x.GuestID == GuestID).FirstOrDefault(); if (guest == null) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Misafir bulunamadı." } }); } if (guest.RowStatus == (int)Enums.RowStatus.PASSIVE) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Misafir zaten daha önce silinmiş." } }); } guest.DtUpdate = DateTime.Now; guest.RowStatus = (int)Enums.RowStatus.PASSIVE; _context.SaveChanges(); return(new GuestDto(guest)); }
public UserDto SetUser(UserDto dto, dugunEntities _context) { #region Server Validation if (!Utils.ValidEmail(dto.EMail)) { return new UserDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Email adresi geçersizdir." } } } ; #endregion #region Email'e göre sorgulama User entity = _context.User.Where(x => x.EMail == dto.EMail).FirstOrDefault(); if (entity != null) { return new UserDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Bu Email adresi zaten kayıtlıdır." } } } ; #endregion entity = new User(); entity.Name = dto.Name; entity.Surname = dto.Surname; entity.EMail = dto.EMail; entity.UserTypeID = dto.UserTypeID; entity.DtInsert = DateTime.Now; entity.RowStatus = (int)Enums.RowStatus.PASSIVE; entity.Password = StringCipher.Encrypt(dto.Password, "password"); entity.DtInsert = DateTime.Now; entity.TelNo = dto.TelNo; entity.DugunID = dto.DugunID; entity.DugunSalonuID = dto.DugunSalonuID; _context.User.Add(entity); _context.SaveChanges(); return(new UserDto(entity)); } } }
public GuestDto ChangeGuestTable(int GuestID, int newTableID, dugunEntities _context) { Guest guest = _context.Guest.Where(x => x.GuestID == GuestID).FirstOrDefault(); Table table = _context.Table.Where(x => x.TableID == newTableID).FirstOrDefault(); if (guest == null) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Misafir bulunamadı." } }); } if (table == null) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Masa bulunamadı." } }); } if (guest.RowStatus == (int)Enums.RowStatus.PASSIVE) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Misafir silinmiş." } }); } if (GetCurrentCountTable(newTableID, _context) >= table.Count) { return(new GuestDto() { ErrorObject = new ErrorDto() { IsError = true, ErrorMessage = "Ekleyeceğiniz masada yeterli yer bulunmamaktadır." } }); } guest.DtUpdate = DateTime.Now; guest.TableID = newTableID; _context.SaveChanges(); return(new GuestDto(guest)); }
public CategoryDto SetCategory(CategoryDto dto, dugunEntities _context) { Category entity = new Category(); entity.CategoryName = dto.CategoryName; entity.DtInsert = DateTime.Now; entity.RowStatus = (int)Enums.RowStatus.ACTIVE; _context.Category.Add(entity); _context.SaveChanges(); return(new CategoryDto(entity)); }
public MessageDto SetMessage(MessageDto dto, dugunEntities _context) { Message entity = new Message(); if (dto.UserIDSender != 0) { entity.UserIDSender = (int)SessionControl.UserStatus.UserID; } entity.MessageText = dto.MessageText; entity.UserIDReceiver = dto.UserIDReceiver; entity.RowStatus = (int)Enums.RowStatus.ACTIVE; entity.DtInsert = DateTime.Now; entity.IsRead = false; _context.Message.Add(entity); _context.SaveChanges(); return(new MessageDto(entity)); }
public GuestDto SetGuest(GuestDto dto, dugunEntities _context) { Guest entity = new Guest(); entity = new Guest(); entity.Name = dto.Name; entity.Surname = dto.Surname; entity.TelNo = dto.TelNo; entity.State = dto.State; entity.Count = dto.Count; entity.Alcoholic = dto.Alcoholic; entity.TableID = dto.TableID; entity.DugunID = dto.DugunID; entity.CategoryID = dto.CategoryID; entity.ServiceID = dto.ServiceID; entity.DtInsert = DateTime.Now; entity.RowStatus = (int)Enums.RowStatus.ACTIVE; _context.Guest.Add(entity); _context.SaveChanges(); return(new GuestDto(entity)); }