public async Task <IActionResult> Edit(long id, [Bind("Id,Name,AmmountPerDay,Status,CreatedBy,CreatedDate")] AllowanceType allowanceTypes)
        {
            if (id != allowanceTypes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //_context.Update(allowanceType);
                    //await _context.SaveChangesAsync();
                    await allowanceType.Update(allowanceTypes);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AllowanceTypeExists(allowanceTypes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(allowanceTypes));
        }
Пример #2
0
        // GET: AllowanceTypes/Create
        public IActionResult Create()
        {
            AllowanceType allowanceType = new AllowanceType();

            allowanceType.catagoriesList = _context.Category.ToList();
            return(View(allowanceType));
        }
Пример #3
0
 public void AllowanceTypeTest(string input, AllowanceType expected)
 {
     JsonDoc.Assert <EarningsRate, AllowanceType>(
         input: new JsonDoc.String(nameof(EarningsRate.AllowanceType), input),
         toProperty: x => x.AllowanceType,
         shouldBe: expected
         );
 }
Пример #4
0
 public static AllowanceTypeModel CreateFromServerToClient(this AllowanceType source)
 {
     return(new AllowanceTypeModel
     {
         TypeId = source.TypeId,
         TypeTitle = source.TypeTitle,
         RecCreatedBy = source.RecCreatedBy,
         RecLastUpdatedBy = source.RecLastUpdatedBy,
         RecCreatedDate = source.RecCreatedDate,
         RecLastUpdatedDate = source.RecLastUpdatedDate
     });
 }
        public ActionResult Insert(AllowanceType data)
        {
            AllowanceType Allowancetypess = new AllowanceType();

            Allowancetypess.Name           = data.Name;
            Allowancetypess.Recurring      = data.Recurring;
            Allowancetypess.AllowanceType1 = data.AllowanceType1;
            Allowancetypess.SequenceNumber = data.SequenceNumber;
            db.AllowanceTypes.Add(Allowancetypess);
            db.SaveChanges();
            db.Entry(Allowancetypess).State = System.Data.Entity.EntityState.Modified;
            return(Json("Saved Successfully"));
        }
Пример #6
0
        public async Task <IActionResult> Create(AllowanceType allowanceType)
        {
            if (ModelState.IsValid)
            {
                allowanceType.CreatedOn  = DateTime.Now;
                allowanceType.IsActive   = true;
                allowanceType.Categories = JsonConvert.SerializeObject(allowanceType.catagoriesList.Where(e => e.IsSelected));
                _context.Add(allowanceType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(allowanceType));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,Name,AmmountPerDay,Status,CreatedBy,CreatedDate")] AllowanceTypeViewModel allowanceTypes)
        {
            if (ModelState.IsValid)
            {
                AllowanceType alt = new AllowanceType()
                {
                    Name          = allowanceTypes.Name,
                    AmmountPerDay = allowanceTypes.AmmountPerDay,
                    Status        = allowanceTypes.Status,

                    CreatedBy   = allowanceTypes.CreatedBy,
                    CreatedDate = DateTime.Now
                };
                await allowanceType.Save(alt);

                //_context.Add(allowanceType);
                //await _context.SaveChangesAsync();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(allowanceTypes));
        }
Пример #8
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                AllowanceType s = new AllowanceType();
                s.recordId = index;
                s.isCash   = false;

                s.name = "";
                PostRequest <AllowanceType> req = new PostRequest <AllowanceType>();
                req.entity = s;
                PostResponse <AllowanceType> r = _employeeService.ChildDelete <AllowanceType>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Name,AmmountPerDay,Status,CreatedBy,CreatedDate")] AllowanceTypeViewModel allowanceTypes)
        {
            if (ModelState.IsValid)
            {
                var           userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                AllowanceType alt    = new AllowanceType()
                {
                    Name          = allowanceTypes.Name,
                    AmmountPerDay = allowanceTypes.AmmountPerDay,
                    Status        = allowanceTypes.Status,

                    CreatedBy   = userId,
                    CreatedDate = DateTime.Now
                };
                await allowanceType.Save(alt);

                //_context.Add(allowanceType);
                //await _context.SaveChangesAsync();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(allowanceTypes));
        }
Пример #10
0
        public async Task <IActionResult> Edit(int id, AllowanceType allowanceType)
        {
            if (id != allowanceType.AllowanceTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var _allowanceType = await _context.AllowanceType.FindAsync(id);

                    _allowanceType.ModifiedOn         = DateTime.Now;
                    _allowanceType.AllowanceTypeName  = allowanceType.AllowanceTypeName;
                    _allowanceType.AllowanceTypePrice = allowanceType.AllowanceTypePrice;
                    _allowanceType.IsActive           = allowanceType.IsActive;
                    _allowanceType.Categories         = JsonConvert.SerializeObject(allowanceType.catagoriesList.Where(e => e.IsSelected));

                    _context.Update(_allowanceType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AllowanceTypeExists(allowanceType.AllowanceTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(allowanceType));
        }
Пример #11
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            //Getting the id to check if it is an Add or an edit as they are managed within the same form.


            string        obj = e.ExtraParams["values"];
            AllowanceType b   = JsonConvert.DeserializeObject <AllowanceType>(obj);

            string id = e.ExtraParams["id"];

            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <AllowanceType> request = new PostRequest <AllowanceType>();

                    request.entity = b;
                    PostResponse <AllowanceType> r = _employeeService.ChildAddOrUpdate <AllowanceType>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                    else
                    {
                        b.recordId = r.recordId;
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <AllowanceType> request = new PostRequest <AllowanceType>();
                    request.entity = b;
                    PostResponse <AllowanceType> r = _employeeService.ChildAddOrUpdate <AllowanceType>(request);                      //Step 1 Selecting the object or building up the object for update purpose

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (!r.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);
                        record.Commit();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditRecordWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }
Пример #12
0
 public async Task Update(AllowanceType s)
 {
     context.Update(s);
     await context.SaveChangesAsync();
 }
Пример #13
0
 public async Task Save(AllowanceType c)
 {
     context.Add(c);
     await context.SaveChangesAsync();
 }
Пример #14
0
 public async Task Delete(AllowanceType sa)
 {
     context.Remove(sa);
     await context.SaveChangesAsync();
 }