public List <EstimationDetailsModel> GetEstimationDetailsByID(EstimationDetailsModel model, Guid id)
        {
            List <EstimationDetail> MasterDataList;
            Estimation Estimation;
            List <EstimationDetailsModel> estimationlist     = new List <EstimationDetailsModel>();
            EstimationDetailsModel        estimationtemplate = new EstimationDetailsModel();

            try
            {
                MasterDataList = _dbContext.EstimationDetails.ToList();
                //Estimation = MasterDataList.Find(item => item.ID == model.ID);
                if (MasterDataList != null)
                {
                    foreach (EstimationDetail a in MasterDataList)
                    {
                        if (a.EstimationID == id)
                        {
                            estimationtemplate = Mapper.Map <EstimationDetail, EstimationDetailsModel>(a);
                            estimationlist.Add(estimationtemplate);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(estimationlist);
        }
        public HttpResponseMessage GetEstimationDetailsList(BaseViewModel model, Guid EstimationID)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    var itemList       = new List <EstimationDetailsModel>();
                    var estimationList = _service.GetEstimationDetailsListByID(model, EstimationID);
                    estimationList.ForEach(item =>
                    {
                        var detailsModel = new EstimationDetailsModel
                        {
                            ID = item.ID,
                            SourceLanguageID        = item.SourceLanguageID,
                            TargetLanguageID        = item.TargetLanguageID,
                            UnitPriceTime           = Convert.ToInt16(item.UnitPriceTime),
                            UnitPriceSubTotal       = Convert.ToDecimal(item.UnitPriceSubTotal),
                            DiscountRate            = Convert.ToDecimal(item.DiscountRate),
                            DiscountedPrice         = Convert.ToDecimal(item.DiscountedPrice),
                            EstimationPrice         = Convert.ToDecimal(item.EstimationPrice),
                            StudioPrice             = Convert.ToDecimal(item.StudioPrice),
                            StudioPriceTime         = Convert.ToDecimal(item.StudioPriceTime),
                            EditPrice               = Convert.ToDecimal(item.EditPrice),
                            EditPriceTime           = Convert.ToInt16(item.EditPriceTime),
                            StudioPriceSubTotal     = Convert.ToDecimal(item.StudioPriceSubTotal),
                            StudioPriceDiscountRate = Convert.ToDecimal(item.StudioPriceDiscountRate),
                            StudioDiscountedPrice   = Convert.ToDecimal(item.StudioDiscountedPrice),
                            TotalAfterDiscount      = Convert.ToDecimal(item.TotalAfterDiscount),
                            NumberOfPeople          = Convert.ToInt16(item.NumberOfPeople),
                            Total           = Convert.ToDecimal(item.Total),
                            PaymentRate     = Convert.ToDecimal(item.PaymentRate),
                            ExpectedPayment = Convert.ToDecimal(item.ExpectedPayment),
                        };

                        itemList.Add(detailsModel);
                    });
                    if (estimationList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, itemList));
                    }
                    else
                    {
                        string message = "Error in getting Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Пример #3
0
 public HttpResponseMessage GetTranslationEstimations(BaseViewModel model, Guid EstimationID)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var itemList       = new List <EstimationDetailsModel>();
             var estimationList = _service.GetAllTranscriptionEstimationDetailsList(model, EstimationID);
             estimationList.ForEach(item => {
                 var detailsModel = new EstimationDetailsModel {
                     ID = item.ID
                     , SourceLanguageID = item.SourceLanguageID
                     , TargetLanguageID = item.TargetLanguageID
                     , Contents         = item.Contents
                     , UnitPrice1       = Convert.ToDecimal(item.UnitPrice1 ?? 0)
                     , LengthMinute     = Convert.ToDecimal(item.LengthMinute ?? 0)
                     , Discount1        = Convert.ToDecimal(item.Discount1 ?? 0)
                     , WithTranslation  = item.WithTranslation ?? false
                     , ExcludeTax       = item.ExcludeTax ?? false
                                          //, EstimationPrice = (decimal)(item.UnitPrice1 * item.LengthMinute)
                                          //, DiscountRate = ((item.Discount1 / (item.UnitPrice1 * item.LengthMinute) * 100))
                                          //, Total = ((item.UnitPrice1 * item.LengthMinute) - item.Discount1)
                                          //, AvgUnitPrice = 0 ExcludedTaxCost
                 };
                 itemList.Add(detailsModel);
             });
             if (estimationList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, itemList));
             }
             else
             {
                 string message = "Error in getting Data";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
 public HttpResponseMessage GetSpecificEstimation(EstimationDetailsModel model, Guid ID)
 {
     try
     {
         var estimation = _service.GetEstimationDetailsByID(model, ID);
         if (estimation != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, estimation));
         }
         else
         {
             string message = "Error in getting Data";
             return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Пример #5
0
 public HttpResponseMessage GetList(BaseViewModel model, Guid EstimationID)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var itemList       = new List <EstimationDetailsModel>();
             var estimationList = _service.GetEstimationDetailsListByID(model, EstimationID);
             estimationList.ForEach(item => {
                 var detailsModel = new EstimationDetailsModel {
                     ID               = item.ID,
                     ExcludeTax       = item.ExcludeTax ?? false,
                     Contents         = item.Contents,
                     UnitPrice1       = item.UnitPrice1 ?? 0,
                     PageCount1       = item.PageCount1 ?? 0,
                     Discount1        = item.Discount1 ?? 0,
                     SourceLanguageID = item.SourceLanguageID,
                     TargetLanguageID = item.TargetLanguageID
                 };
                 itemList.Add(detailsModel);
             });
             if (estimationList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, itemList));
             }
             else
             {
                 string message = "Error in getting Data";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
        /* Function to retrive a list of EstimationDetails by Estimaton ID */
        /* Programmed by Ashis Kr. Das */
        public List <EstimationDetailsModel> GetEstimationDetailsListByID(BaseViewModel model, string EstimationID)
        {
            SqlCommand                    cmd;
            SqlDataReader                 DataReader;
            EstimationDetailsModel        DetailsModel;
            List <EstimationDetailsModel> DataList = new List <EstimationDetailsModel>();

            try
            {
                _sqlConnService.OpenConnection();
                cmd             = new SqlCommand("SP_GetAllEstimationDetails", _sqlConnService.CreateConnection());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@EstimationID", Guid.Parse(EstimationID));
                cmd.Parameters.AddWithValue("@CultureId", model.CurrentCulture);
                DataReader = cmd.ExecuteReader();
                while (DataReader.Read() == true)
                {
                    DetailsModel                       = new EstimationDetailsModel();
                    DetailsModel.ID                    = Guid.Parse(DataReader["ID"].ToString());
                    DetailsModel.EstimationID          = Guid.Parse(DataReader["EstimationID"].ToString());
                    DetailsModel.SourceLanguageID      = Guid.Parse(DataReader["SourceLanguageID"].ToString());
                    DetailsModel.TargetLanguageID      = Guid.Parse(DataReader["TargetLanguageID"].ToString());
                    DetailsModel.ServiceTypeID         = Guid.Parse(DataReader["ServiceType"].ToString());
                    DetailsModel.UnitPrice1            = Convert.ToDecimal(DataReader["UnitPrice1"].ToString());
                    DetailsModel.PageCount1            = Convert.ToInt32(DataReader["PageCount1"].ToString());
                    DetailsModel.Discount1             = Convert.ToDecimal(DataReader["Discount1"].ToString());
                    DetailsModel.UnitPrice2            = Convert.ToDecimal(DataReader["UnitPrice2"].ToString());
                    DetailsModel.PageCount2            = Convert.ToInt32(DataReader["PageCount2"].ToString());
                    DetailsModel.Discount2             = Convert.ToDecimal(DataReader["Discount2"].ToString());
                    DetailsModel.UnitPrice3            = Convert.ToDecimal(DataReader["UnitPrice3"].ToString());
                    DetailsModel.PageCount3            = Convert.ToInt32(DataReader["PageCount3"].ToString());
                    DetailsModel.Discount3             = Convert.ToDecimal(DataReader["Discount3"].ToString());
                    DetailsModel.UnitPrice4            = Convert.ToDecimal(DataReader["UnitPrice4"].ToString());
                    DetailsModel.PageCount4            = Convert.ToInt32(DataReader["PageCount4"].ToString());
                    DetailsModel.Discount4             = Convert.ToDecimal(DataReader["Discount4"].ToString());
                    DetailsModel.UnitPrice5            = Convert.ToDecimal(DataReader["UnitPrice5"].ToString());
                    DetailsModel.PageCount5            = Convert.ToInt32(DataReader["PageCount5"].ToString());
                    DetailsModel.Discount5             = Convert.ToDecimal(DataReader["Discount5"].ToString());
                    DetailsModel.BasicTime             = Convert.ToInt32(DataReader["BasicTime"].ToString());
                    DetailsModel.AdditionalBasicAmount = Convert.ToDecimal(DataReader["AdditionalBasicAmount"].ToString());
                    DetailsModel.ExtraTime             = Convert.ToInt32(DataReader["ExtraTime"].ToString());
                    //DetailsModel.LastnightTime = Convert.ToInt32(DataReader["LastnightTime"].ToString());
                    //DetailsModel.MovingTime = Convert.ToInt32(DataReader["MovingTime"].ToString());
                    DetailsModel.BasicAmount       = Convert.ToDecimal(DataReader["BasicAmount"].ToString());
                    DetailsModel.ExtensionAmount   = Convert.ToDecimal(DataReader["ExtensionAmount"].ToString());
                    DetailsModel.ExtraAmount       = Convert.ToDecimal(DataReader["ExtraAmount"].ToString());
                    DetailsModel.LateAtNightAmount = Convert.ToDecimal(DataReader["LateAtNightAmount"].ToString());
                    //DetailsModel.MovingAmount = Convert.ToDecimal(DataReader["MovingAmount"].ToString());
                    DetailsModel.NumberOfDays      = Convert.ToInt32(DataReader["NumberOfDays"].ToString());
                    DetailsModel.NumberOfPeople    = Convert.ToInt32(DataReader["NumberOfPeople"].ToString());
                    DetailsModel.OtherAmount       = Convert.ToDecimal(DataReader["OtherAmount"].ToString());
                    DetailsModel.CertificateAmount = Convert.ToDecimal(DataReader["CertificateAmount"].ToString());
                    DetailsModel.ExcludeTax        = Convert.ToBoolean(DataReader["ExcludeTax"].ToString());
                    DetailsModel.Contents          = DataReader["Contents"].ToString();
                    DetailsModel.LengthMinute      = Convert.ToDecimal(DataReader["LengthMinute"].ToString());
                    DetailsModel.WithTranslation   = Convert.ToBoolean(DataReader["WithTranslation"].ToString());
                    DataList.Add(DetailsModel);
                }
                DataReader.Close();
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "Estimation", message);
                throw new Exception(message);
            }
            finally
            {
                _sqlConnService.CloseConnection();
            }
            return(DataList);
        }