Ejemplo n.º 1
0
        public IHttpActionResult PostCustomerNotes(CustomerNotesDTO oDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = subsiteofficeconfigService.SaveCustomerNoteInfo(oDto);

            if (result == Guid.Empty)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
        /// <summary>
        /// This method is used to Save and Update the Customer Note Infomration Dtails
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Guid SaveCustomerNoteInfo(CustomerNotesDTO dto)
        {
            int          entityState = 0;
            CustomerNote model       = new CustomerNote();

            if (dto != null)
            {
                Guid refId;
                model.Id    = Guid.NewGuid();
                entityState = (int)System.Data.Entity.EntityState.Added;

                bool IsRefId = Guid.TryParse(dto.RefId, out refId);
                if (!IsRefId)
                {
                    return(Guid.Empty);
                }
                model.RefId           = refId;
                model.Note            = dto.Note;
                model.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate = System.DateTime.Now;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.CustomerNotes.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(model.Id);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/SaveCustomerNoteInfo", model.RefId);
                return(Guid.Empty);

                throw;
            }
        }
 /// <summary>
 /// This Method is used to Get the Customer Notes details by ID
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public IQueryable <CustomerNotesDTO> GetCustomerNotesById(Guid userid)
 {
     try
     {
         db = new DatabaseEntities();
         var data = (from cu in db.CustomerNotes where cu.RefId == userid select cu);
         List <CustomerNotesDTO> lstsbcustnotes = new List <CustomerNotesDTO>();
         foreach (var itm in data)
         {
             CustomerNotesDTO customernotesDTO = new CustomerNotesDTO();
             customernotesDTO.Note        = itm.Note;
             customernotesDTO.RefName     = db.emp_CustomerInformation.Where(o => o.Id == itm.RefId).Select(a => a.CompanyName).FirstOrDefault();
             customernotesDTO.CreatedDate = itm.CreatedDate.ToString("MM/dd/yyyy hh:mm tt");
             lstsbcustnotes.Add(customernotesDTO);
         }
         return(lstsbcustnotes.OrderByDescending(a => a.CreatedDate).AsQueryable());
     }
     catch (Exception ex)
     {
         EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/GetCustomerNotesById", Guid.Empty);
         return(null);
     }
 }