public Int32 insertPayType(Models.MstPayType payType)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                Data.MstPayType newPayType = new Data.MstPayType();
                newPayType.PayType         = payType.PayType;
                newPayType.AccountId       = payType.AccountId;
                newPayType.IsLocked        = payType.IsLocked;;
                newPayType.CreatedById     = userId;
                newPayType.CreatedDateTime = DateTime.Now;
                newPayType.UpdatedById     = userId;
                newPayType.UpdatedDateTime = DateTime.Now;

                db.MstPayTypes.InsertOnSubmit(newPayType);
                db.SubmitChanges();

                return(newPayType.Id);
            }
            catch
            {
                return(0);
            }
        }
        public Int32 insertPayType(Models.MstPayType payType)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                Data.MstPayType newPayType = new Data.MstPayType();
                newPayType.PayType = payType.PayType;
                newPayType.AccountId = payType.AccountId;
                newPayType.IsLocked = payType.IsLocked; ;
                newPayType.CreatedById = userId;
                newPayType.CreatedDateTime = DateTime.Now;
                newPayType.UpdatedById = userId;
                newPayType.UpdatedDateTime = DateTime.Now;

                db.MstPayTypes.InsertOnSubmit(newPayType);
                db.SubmitChanges();

                return newPayType.Id;
            }
            catch
            {
                return 0;
            }
        }
Beispiel #3
0
        public Int32 postPeriod()
        {
            try
            {
                Data.MstPayType newPayType = new Data.MstPayType();
                newPayType.PayType   = "n/a";
                newPayType.AccountId = AccountId();
                db.MstPayTypes.InsertOnSubmit(newPayType);
                db.SubmitChanges();

                return(newPayType.Id);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
        public int Post(Models.MstPayType payType)
        {
            try
            {
                Data.MstPayType newPayType = new Data.MstPayType();

                newPayType.Id = payType.Id;
                newPayType.PayType = payType.PayType;
                newPayType.AccountId = payType.AccountId;

                db.MstPayTypes.InsertOnSubmit(newPayType);
                db.SubmitChanges();

                return  newPayType.Id;
            }
            catch
            {
                return 0;
            }
        }
Beispiel #5
0
        public HttpResponseMessage AddPayType(Entities.MstPayType objPayType)
        {
            try
            {
                var currentUser = from d in db.MstUsers
                                  where d.UserId == User.Identity.GetUserId()
                                  select d;

                if (currentUser.Any())
                {
                    var currentUserId = currentUser.FirstOrDefault().Id;

                    var userForms = from d in db.MstUserForms
                                    where d.UserId == currentUserId &&
                                    d.SysForm.FormName.Equals("SystemTables")
                                    select d;

                    if (userForms.Any())
                    {
                        if (userForms.FirstOrDefault().CanAdd)
                        {
                            var accounts = from d in db.MstAccounts.OrderBy(d => d.Account)
                                           where d.IsLocked == true
                                           select d;

                            if (accounts.Any())
                            {
                                Data.MstPayType newPayType = new Data.MstPayType
                                {
                                    PayType         = objPayType.PayType,
                                    AccountId       = objPayType.AccountId,
                                    IsLocked        = true,
                                    CreatedById     = currentUserId,
                                    CreatedDateTime = DateTime.Now,
                                    UpdatedById     = currentUserId,
                                    UpdatedDateTime = DateTime.Now
                                };

                                db.MstPayTypes.InsertOnSubmit(newPayType);
                                db.SubmitChanges();

                                String newObject = at.GetObjectString(newPayType);
                                at.InsertAuditTrail(currentUser.FirstOrDefault().Id, GetType().Name, MethodBase.GetCurrentMethod().Name, "NA", newObject);

                                return(Request.CreateResponse(HttpStatusCode.OK, newPayType.Id));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.NotFound, "No account found. Please setup at least one account for payTypes."));
                            }
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no rights to add payType."));
                        }
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no access for this system table page."));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Theres no current user logged in."));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's went wrong from the server."));
            }
        }