Beispiel #1
0
        public List <MessageDto> GetUnreadedMessageList(dugunEntities _context)
        {
            var currentUser            = SessionControl.UserStatus;
            List <MessageDto> messages = new List <MessageDto>();

            if (currentUser != null)
            {
                messages.AddRange(_context.Message.Where(x => x.UserIDReceiver == currentUser.UserID && x.IsRead == false).OrderByDescending(x => x.DtInsert).
                                  Select(x => new MessageDto()
                {
                    UserIDReceiver = x.UserIDReceiver,
                    DtInsert       = x.DtInsert,
                    RowStatus      = x.RowStatus,
                    MessageText    = x.MessageText,
                    UserIDSender   = x.UserIDSender,
                    User           = x.UserIDSender != null ? new UserDto()
                    {
                        UserID = (int)x.UserIDSender,
                        Name   = x.User.Name,
                    } : null,
                }).ToList());
            }

            return(messages);
        }
Beispiel #2
0
        public List <MessageDto> GetReceivedMessages(int page, int size, dugunEntities _context)
        {
            var currentUser            = SessionControl.UserStatus;
            List <MessageDto> messages = null;

            messages = _context.Message
                       .Where(x => x.UserIDReceiver == currentUser.UserID)
                       .OrderByDescending(x => x.DtInsert)
                       .Skip(page * size).Take(size)
                       .Select(x => new MessageDto()
            {
                UserIDSender   = x.UserIDSender,
                UserIDReceiver = x.UserIDReceiver,
                DtInsert       = x.DtInsert,
                RowStatus      = x.RowStatus,
                MessageID      = x.MessageID,
                MessageText    = x.MessageText,
                User1          = new UserDto()
                {
                    UserID = (int)x.UserIDReceiver,
                    Name   = x.User1.Name,
                }
            }).ToList();

            return(messages);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        public int GetCurrentCountTable(int TableID, dugunEntities _context)
        {
            List <GuestDto> guestList = _context.Guest.Where(x => x.TableID == TableID && x.RowStatus == (int)Enums.RowStatus.ACTIVE)
                                        .Select(x => new GuestDto
            {
                GuestID = x.GuestID,
            }).ToList();

            return(guestList.Count());
        }
Beispiel #5
0
        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));
        }
    }
}
Beispiel #6
0
        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));
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
        public UserDto GetUser(int userID, dugunEntities _context)
        {
            var entity = _context.User.FirstOrDefault(x => x.UserID == userID && x.RowStatus == (int)Enums.RowStatus.ACTIVE);

            UserDto user = new UserDto();

            user = _context.User.Where(x => x.UserID == userID).Select(x => new UserDto()
            {
                UserID        = x.UserID,
                Name          = x.Name,
                Surname       = x.Surname,
                DugunSalonuID = x.DugunSalonuID,
                DugunID       = x.DugunID,
                EMail         = x.EMail,
                TelNo         = x.TelNo,
                UserName      = x.UserName,
                DtInsert      = x.DtInsert,
                DtUpdate      = x.DtUpdate,
            }).FirstOrDefault();
            return(user);
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        public List <GuestDto> GetGuestsByTable(int TableID, dugunEntities _context)
        {
            List <GuestDto> guestList = _context.Guest.Where(x => x.TableID == TableID && x.RowStatus == (int)Enums.RowStatus.ACTIVE)
                                        .Select(x => new GuestDto
            {
                GuestID    = x.GuestID,
                Name       = x.Name,
                Surname    = x.Surname,
                TelNo      = x.TelNo,
                State      = x.State,
                Count      = x.Count,
                Alcoholic  = x.Alcoholic,
                TableID    = x.TableID,
                DugunID    = x.DugunID,
                CategoryID = x.CategoryID,
                ServiceID  = x.ServiceID,
                DtInsert   = x.DtInsert,
                DtUpdate   = x.DtUpdate,
            }).ToList();

            return(guestList);
        }
Beispiel #12
0
        public GuestDto GetGuest(int GuestID, dugunEntities _context)
        {
            var entity = _context.Guest.FirstOrDefault(x => x.GuestID == GuestID && x.RowStatus == (int)Enums.RowStatus.ACTIVE);

            GuestDto Guest = new GuestDto();

            Guest = _context.Guest.Where(x => x.GuestID == GuestID).Select(x => new GuestDto()
            {
                GuestID    = x.GuestID,
                Name       = x.Name,
                Surname    = x.Surname,
                TelNo      = x.TelNo,
                State      = x.State,
                Count      = x.Count,
                Alcoholic  = x.Alcoholic,
                TableID    = x.TableID,
                DugunID    = x.DugunID,
                CategoryID = x.CategoryID,
                ServiceID  = x.ServiceID,
                DtInsert   = x.DtInsert,
                DtUpdate   = x.DtUpdate,
            }).FirstOrDefault();
            return(Guest);
        }
Beispiel #13
0
        public List <GuestDto> GetGuestsByWedding(int DugunID, int page, int size, dugunEntities _context)
        {
            List <GuestDto> discountList = _context.Guest.Where(x => x.DugunID == DugunID && x.RowStatus == (int)Enums.RowStatus.ACTIVE)
                                           .Skip(page * size)
                                           .Take(size)
                                           .Select(x => new GuestDto
            {
                GuestID    = x.GuestID,
                Name       = x.Name,
                Surname    = x.Surname,
                TelNo      = x.TelNo,
                State      = x.State,
                Count      = x.Count,
                Alcoholic  = x.Alcoholic,
                TableID    = x.TableID,
                DugunID    = x.DugunID,
                CategoryID = x.CategoryID,
                ServiceID  = x.ServiceID,
                DtInsert   = x.DtInsert,
                DtUpdate   = x.DtUpdate,
            }).ToList();

            return(discountList);
        }
Beispiel #14
0
 public Nullable <int> GetNewMessageCount(dugunEntities _context)
 {
     return(_context.Message.Count(x => x.UserIDReceiver == SessionControl.UserStatus.UserID && x.RowStatus == (int)Enums.RowStatus.ACTIVE && x.IsRead == false));
 }
Beispiel #15
0
        public static object Invoke <TResponse>(Expression <Func <TResponse> > function, object manager)
        {
            var fbody = function.Body as MethodCallExpression;

            if (fbody == null || fbody.Method == null)
            {
                throw new InvalidOperationException("Expression must be a method call.");
            }

            var method = (typeof(IWinService).GetMethod(fbody.Method.Name));

            if (method != null)
            {
                var attributes = method.GetCustomAttributes(true);
                if (attributes != null)
                {
                    List <AuthenticationAttribute> attr = attributes.Where(t => t.GetType() == typeof(AuthenticationAttribute)).Select(x => x as AuthenticationAttribute).ToList();

                    for (int i = 0; i < attr.Count; i++)
                    {
                        if (attr[i].Auth == AuthenticationType.Admin)
                        {
                            return(null);
                        }
                    }
                }
            }

            try
            {
                IList <object>           managerInputs = new List <object>();
                IList <MemberExpression> arguments     = fbody.Arguments.OfType <MemberExpression>().ToList();

                for (int argIndex = 0; argIndex < arguments.Count; argIndex++)
                {
                    managerInputs.Add(ExpressionExtension.ExtractConstants(arguments[argIndex]).ToList());
                }

                using (var context = new dugunEntities())
                {
                    context.Configuration.ProxyCreationEnabled = false;

                    object[] dynamicArgs = null;
                    if (managerInputs.Count > 0)
                    {
                        dynamicArgs = new object[managerInputs.Count + 1];
                        dynamicArgs[dynamicArgs.Length - 1] = context;

                        for (int index = 0; index < dynamicArgs.Length - 1; index++)
                        {
                            dynamicArgs[index] = ((List <object>)managerInputs[index])[0];
                        }
                    }

                    return(managerInputs.Count > 0 ? fbody.Method.Invoke(manager, dynamicArgs) :
                           fbody.Method.Invoke(manager, new object[] { context }));
                }
            }
            catch (TargetInvocationException tiex)
            {
                Exception dex = tiex.InnerException;
                throw dex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }