Example #1
0
        public async Task <bool> Update(appraiseditem model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var result = await FindById(model.AppraiseId);

                    if (result != null)
                    {
                        uow.AppraisedItemRepository.Update(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        public async Task <JsonResult> SaveAppraisedItem(AppraisalViewModel item)
        {
            try
            {
                appraiseditem model = null;

                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(item.AppraiseId.ToString()) || item.AppraiseId.ToString() == "0")
                {
                    //DateTime dt = DateTime.ParseExact(item.AppraiseDate, "yyyy/MM/dd", CultureInfo.InvariantCulture);

                    model = new appraiseditem();
                    model.AppraiseDate      = DateTime.Parse(item.AppraiseDate);
                    model.AppraiseNo        = item.AppraiseNo;
                    model.ItemTypeId        = item.ItemTypeId;
                    model.ItemCategoryId    = item.ItemCategoryId;
                    model.ItemName          = item.ItemName;
                    model.Weight            = item.Weight;
                    model.AppraisedValue    = item.AppraisedValue;
                    model.Remarks           = item.Remarks;
                    model.CustomerFirstName = item.CustomerFirstName;
                    model.CustomerLastName  = item.CustomerLastName;
                    model.IsPawned          = false;
                    model.CreatedAt         = DateTime.Now;
                    model.CreatedBy         = "";

                    var result = await _appraisalService.Save(model);

                    success = result;
                    if (result)
                    {
                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Duplicate entry.";
                    }
                }
                else
                {
                    model = await _appraisalService.FindById(item.AppraiseId);

                    model.ItemTypeId        = item.ItemTypeId;
                    model.ItemCategoryId    = item.ItemCategoryId;
                    model.ItemName          = item.ItemName;
                    model.Weight            = item.Weight;
                    model.AppraisedValue    = item.AppraisedValue;
                    model.Remarks           = item.Remarks;
                    model.CustomerFirstName = item.CustomerFirstName;
                    model.CustomerLastName  = item.CustomerLastName;

                    var result = await _appraisalService.Update(model);

                    success = result;
                    if (result)
                    {
                        message = "Successfully updated.";
                    }
                    else
                    {
                        message = "Error saving data. Please contact administrator.";
                    }
                }

                return(Json(new { success = success, message = message }));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }